import { getCateListAPI } from '@/api/cate'
import { getTagListAPI } from '@/api/tag'

// 状态
const state = {
  tags: [],
  cates: []
}
// 修改状态
const mutations = {
  setTags(state, data) {
    state.tags = data
  },
  setCates(state, data) {
    state.cates = data
  }
}

const actions = {
  async getTags({ commit }) {
    const res = await getTagListAPI()
    commit('setTags', res.data.result)
  },
  async getCates({ commit }) {
    const res = await getCateListAPI()
    commit('setCates', res.data.result)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
